package com.shujia.day14;

import java.io.*;

public class Code05BufferInputStream {
    public static void main(String[] args) throws IOException {
        /*
            BufferedInputStream 底层是对读取的数据进行做了缓存，提高了读取的速度
         */

        FileInputStream fileInputStream = new FileInputStream("data/copy/a.txt");
        BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);

        int read = bufferedInputStream.read();
        System.out.println((char) read);
        System.out.println((char) bufferedInputStream.read());

        byte[] bytes = new byte[4];
        int read1 = bufferedInputStream.read(bytes);
        System.out.println(read1);
        System.out.println(new String(bytes));


        while ((read =bufferedInputStream.read())!= -1){
            System.out.print((char) read);
        }

        bufferedInputStream.close();

    }
}
